package naughtydog.threads.concurrency;

import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

public class LongGenerator implements Runnable {
	
	private final static long GENERATION_TIME_MS = 650;
	private IModel theModel;
	
	public LongGenerator(IModel theModel) {
		this.theModel = theModel;
	}

	@Override
	public void run() {
		for(;;) {
			generateInt();
			try {
				Thread.sleep(GENERATION_TIME_MS);
			} catch (InterruptedException e) {
				return;
			}
		}
	}
	
	//task che deve compiere
	private void generateInt() {
		Random random = new Random();
		theModel.setaLong((long)(random.nextGaussian() * 10));
	}

}
